Home:ALL Converter>No reverse iterators for `std::filesystem::path`?

No reverse iterators for `std::filesystem::path`?

Ask Time:2021-07-29T11:59:10         Author:Adrian McCarthy

Json Formatter

Is there a technical reason why std::filesystem::path doesn't offer reverse iterators (i.e., rbegin and rend)?

If I have a std::filesystem::path for /a/b/c/b/d/b/e and I want to find the first component that matches b, I can use std::find(p.begin(), p.end(), fs::path("b")).

But if I want to find the last component that matches b, I can't just switch to reverse iterators. I can write my own loop, but it seems like this would be a common operation that would have been "almost free" to implement.

Is there something about the design of the interface that would make it difficult to provide reverse iterators?

Author:Adrian McCarthy,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/68569873/no-reverse-iterators-for-stdfilesystempath
yy